package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

public class SrzBodyJudgeActivity extends AbstractControlActivity implements
		OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_body_judge_shirezhi);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_srz_1, "湿热质油腻");
		addRadioGroupView(R.id.rad_srz_2, "湿热质痤疮");
		addRadioGroupView(R.id.rad_srz_3, "湿热质口苦");
		addRadioGroupView(R.id.rad_srz_4, "湿热质黏滞");
		addRadioGroupView(R.id.rad_srz_5, "湿热质发热");
		addRadioGroupView(R.id.rad_srz_6, "湿热质色黄");
		addRadioGroupView(R.id.rad_srz_7, "湿热质潮湿");

		setButtonListener(this, R.id.btn_next, R.id.btn_previous);

		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			// 保存湿热质转化分到properties文件
			saveBodyJudgeScore(createDate, "湿热质", R.id.rad_srz_1,
					R.id.rad_srz_2, R.id.rad_srz_3, R.id.rad_srz_4,
					R.id.rad_srz_5, R.id.rad_srz_6, R.id.rad_srz_7);
			intent.setClass(this, XyzBodyJudgeActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			finish();
			break;
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, DszBodyJudgeActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			finish();
			break;
		default:
			break;
		}
	}
}
